package com.muyu.controller;

import com.muyu.entity.QueryUserInfoModel;
import com.muyu.entity.UserEntity;
import com.muyu.service.UserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: Knife4jController
 * @Author: Zirun.Xin
 * @Date: 2025/1/9 17:07
 * @Version: 1.0
 * @Description: Knife4j控制层
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/user")
public class Knife4jController {

    private static final Logger log = LoggerFactory.getLogger(Knife4jController.class);
    /**
     * 用户业务层
     */
    private final UserService userService;

    /**
     * 获取用户信息
     * @return 响应结果集
     */
    @GetMapping(value = "/get-user-list")
    @ApiOperation(value = "获取用户信息", notes = "获取用户信息")
    public List<UserEntity> getUserList(@RequestHeader(value = HttpHeaders.AUTHORIZATION) String token) {
        log.info("token:{}", token);
        return userService.getUserList();
    }


    /**
     * 根据多个id等参数联合查询用户信息
     * @param queryUserInfoModel 查询用户参数体集合
     * @return 响应结果集
     */
    @PostMapping(value = "/get-user-by-ids")
    @ApiOperation(value = "根据多个id等参数联合查询用户信息", notes = "根据多个id等参数联合查询用户信息")
    public List<UserEntity> getUserByIds(@RequestBody QueryUserInfoModel queryUserInfoModel) {
        return userService.getUserByIds(queryUserInfoModel.getUserIds());
    }

    /**
     * 根据性别查询用户信息
     * @param sex 性别
     * @return 响应结果集
     */
    @GetMapping(value = "/get-user-by-sex")
    @ApiOperation(value = "根据性别查询用户信息", notes = "根据性别查询用户信息")
    public List<UserEntity> getUserBySex(@ApiParam(value = "性别", required = true)
                                         @RequestParam(value = "sex") String sex) {
        return userService.getUserBySex(sex);
    }
}
